<script>
export default {
  name: "Message",
  data() {
    return {
      msgList: [
        {
          id: 1,
          title: '新闻1',
          content: '新闻内容1'
        },
        {
          id: 2,
          title: '新闻2',
          content: '新闻内容2'
        },
        {
          id: 3,
          title: '新闻3',
          content: '新闻内容3'
        }
      ]
    }
  }
}
</script>

<template>
  <div>
    <ul>
      <li v-for="item in msgList" :key="item.id">
<!--        跳转路由并携带param参数，to的字符串写法-->
<!--        <router-link :to="`/home/msg/detail/${item.id}/${item.title}`">{{item.title}}</router-link>-->

        <!--        跳转路由并携带param参数，to的对象写法中不允许写path，需要用name -->
        <router-link :to="{
          name: 'xiangqin',
          query: {
            id: item.id,
            title: item.title
          }
        }">
          {{item.title}}
        </router-link>
      </li>
    </ul>
    <hr/>
    <router-view/>
  </div>
</template>

<style scoped>

</style>